//
// Created by Administrator on 2021/10/25.
//

#include "AxiesBufferGeometry.h"

AxiesBufferGeometry::AxiesBufferGeometry() {
    type = GET_CLASS(__FILE__);
    name = type + "_" + id;

    float size = 1.0f;
    this->location = Vector3(0.0f, 0.0f, 0.0f);
    this->vx = Vector3(size, 0.0f, 0.0f);
    this->vy = Vector3(0.0f, size, 0.0f);
    this->vz = Vector3(0.0f, 0.0f, -size);
}

AxiesBufferGeometry::AxiesBufferGeometry(float size){
    type = GET_CLASS(__FILE__);
    name = type + "_" + id;

    this->location = Vector3(0.0f, 0.0f, 0.0f);
    this->vx = Vector3(size, 0.0f, 0.0f);
    this->vy = Vector3(0.0f, size, 0.0f);
    this->vz = Vector3(0.0f, 0.0f, -size);
}

AxiesBufferGeometry::AxiesBufferGeometry(const Vector3& location, const Vector3& vx, const Vector3& vy, const Vector3& vz) {
    type = GET_CLASS(__FILE__);
    name = type + "_" + id;

    this->location = location;
    this->vx = vx;
    this->vy = vy;
    this->vz = vz;
}


void AxiesBufferGeometry::onInit() {
    drawMode = GL_LINES;
    vertices = {
            location.x, location.y, location.z, //o
            vx.x, vx.y, vx.z, //x
            location.x, location.y, location.z, //o
            vy.x, vy.y, vy.z, //y
            location.x, location.y, location.z, //o
            vz.x, vz.y, vz.z, //z
    };

    indices = {
            0, 1,
            2, 3,
            4, 5
    };

    colors = {
            1.0f, 0.0f, 0.0f, 1.0f,
            1.0f, 0.0f, 0.0f, 1.0f,
            0.0f, 1.0f, 0.0f, 1.0f,
            0.0f, 1.0f, 0.0f, 1.0f,
            0.0f, 0.0f, 1.0f, 1.0f,
            0.0f, 0.0f, 1.0f, 1.0f,
    };
    BufferGeometry::onInit();
}




















